<include file="public:no_bs_header" />
<link rel="stylesheet" type="text/css" href="__STATIC__/admin/uploadstyle/css/webuploader.css">
<link rel="stylesheet" type="text/css" href="__STATIC__/admin/uploadstyle/css/diyUpload.css">
<script type="text/javascript" src="__STATIC__/admin/uploadstyle/js/webuploader.html5only.min.js"></script>
<script type="text/javascript" src="__STATIC__/admin/uploadstyle/js/diyUpload.js"></script>

<!--添加文章-->
<form id="info_form" action="{:U('article/add')}" method="post" enctype="multipart/form-data">
<div class="pad_lr_10" style="margin-top: 10px;">
	<div class="col_tab" id="col_tab">
		<ul class="J_tabs tab_but cu_li">
			<li href="#con1" class="current">{:L('article_basic')}</li>
			<li href="#con2">{:L('article_seo')}</li>
		</ul>
		<div class="J_panes">
			<div id="con1" class="content_list pad_10">
				<table width="100%" cellspacing="0" class="table_form">
					<tr>
						<th width="120">{:L('article_cateid')} :</th>
						<td>
							<select class="J_cate_select mr10" data-pid="0" data-uri="{:U('superadmin/article_cate/ajax_getchilds')}" data-selected="">

							</select>
							<input type="hidden" name="cate_id" id="cate_id" value="" /></td>
					</tr>
		            <tr>
						<th>{:L('article_title')} :</th>
						<td>
							<input type="text" name="title" id="title" class="input-text" size="30">
						</td>
					</tr>
		            <tr>
						<th>{:L('author')} :</th>
						<td><input type="text" name="source" id="source" class="input-text" size="30" value="{$author}"></td>
					</tr>
		            <tr>
						<th>{:L('article_img')} :</th>
						<td>
							<div id="box">
								<div id="container" >
								</div>
								<div id="test"></div>
							</div>
							<input type="hidden" name="img" id="img" class="input-text" value="{$article.thumb}" /></td>


						</td>
		 			</tr>
					<tr>
						<th>{:L('publish')} :</th>
		 				<td>
		                	<label><input type="radio" name="status" class="radio_style" value="1"> {:L('yes')} </label>&nbsp;&nbsp;
							<label><input type="radio" name="status" class="radio_style" value="0" checked="checked"> {:L('no')}</label>
						</td>
					</tr>
                    <tr>
						<th>{:L('article_desc')} :</th>
						<td><textarea name="intro" id="abst" style="width:67%;height:50px;resize:none;"></textarea></td>
					</tr>
		            <tr>
						<th>详细内容 :</th>
		                <td><textarea name="content" id="content" style="width:68%;height:400px;visibility:hidden;resize:none;"></textarea></td>
					</tr>
				</table>
			</div>
			<div  id="con2" class="content_list pad_10 hidden">
				<table width="100%" cellspacing="0" class="table_form">
					<tr>
						<th width="120">{:L('seo_title')} :</th>
		 				<td><input type="text" name="seo_title" id="seo_title" class="input-text" size="60"></td>
					</tr>
					<tr>
						<th>{:L('seo_keys')} :</th>
						<td><input type="text" name="seo_keywords" id="seo_keys" class="input-text" size="60"></td>
					</tr>
					<tr>
						<th>{:L('seo_desc')} :</th>
						<td><textarea name="seo_description" id="seo_desc" cols="80" rows="8"></textarea></td>
					</tr>
				</table>
			</div>
        </div>
		<input type="hidden" id="json_cate_list" value='{$cate_list}'>
		<div class="mt10"><input type="button" value="{:L('submit')}" id="dosubmit" name="dosubmit" class="obtn obtn_submit" style="margin:0 0 10px 100px;"><br /><br /><br /></div>
	</div>
</div>
</form>
<include file="public:footer" />
<script charset="utf-8" src="__STATIC__/editor/kindeditor-all-min.js"></script>
<script charset="utf-8" src="__STATIC__/editor/lang/zh-CN.js"></script>

<script>
//$('.J_cate_select').cate_select('请选择');
$(function() {
	//初始化编辑器
	KindEditor.ready(function(K) {
		window.editor = K.create('#content',{
			width: '730px',
			height: '360px',
			afterBlur: function(){this.sync();}
		});
	});

	cate_select_init();
	$('#dosubmit').click(function(){
		var cate_id = $('#cate_id').val();
		var title   = $('#title').val();
		var content = editor.html();
		if(!$.trim(cate_id))
		{
			layer.msg('请选择分类');
			return false;
		}
		if(!$.trim(title))
		{
			layer.msg('请输入文章标题');
			return false;
		}
		if(!$.trim(content))
		{
			layer.msg('请输入文章内容');
			return false;
		}
		$('#info_form').submit();
	});

	$('#test').diyUpload({
		fileNumLimit:1,
		container: 'container', //图片预览容器
		url:"{:U('superadmin/upload/index', array('cate' => 'article'))}",
		success:function( data ) {
			//console.info(data.data.file.name);
			var img_path = '/article/'+ data.data.file.savepath + data.data.file.savename
			$('#img').val(img_path)
		},
		error:function( err ) {
			//console.info( err );
		}

	});
	$('.diyCancel').click(function(){
		$(this).parents('li').remove();
		$('#img').val('')
	})

});
</script>
</body>
</html>